package com.approval.approvalapp.center.acitivty;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.approval.approvalapp.R;
import com.approval.approvalapp.bean.ZdrwXqBean;
import com.approval.approvalapp.util.base.BaseActivity;
import com.approval.approvalapp.util.net.NetRequsetUtil;
import com.approval.approvalapp.util.net.interfacepac.NetDownResponse;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ZdrwXQActivity extends BaseActivity {


    @Bind(R.id.back_iv)
    ImageView backIv;
    @Bind(R.id.titleTv1)
    TextView titleTv1;
    @Bind(R.id.root)
    LinearLayout root;

    @Override
    public int getLayoutId() {
        return R.layout.activity_zdrw_xq;
    }

    @Override
    public void initView() {
        String id = getIntent().getStringExtra("id");
        String m = getIntent().getStringExtra("m");
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("id",id);
        jsonObject.put("m",m);
        NetRequsetUtil.getInstance().netRequestPostJson("v1/center/task_index",
                jsonObject.toString()
                , new NetDownResponse() {
                    @Override
                    public void success(String str) {
                        List<ZdrwXqBean> zdrwXqBeans = JSON.parseArray(str, ZdrwXqBean.class);
                        if (zdrwXqBeans.size() > 0){
                            for (int i = 0; i < zdrwXqBeans.size(); i++) {
                                View view = LayoutInflater.from(ZdrwXQActivity.this).inflate(R.layout.item_xxx, root, false);
                                TextView tv1 = view.findViewById(R.id.tv1);
                                TextView tv2 = view.findViewById(R.id.tv2);
                                TextView tv3 = view.findViewById(R.id.tv3);
                                tv1.setText(zdrwXqBeans.get(i).getContent());
                                tv2.setText("等级: " + zdrwXqBeans.get(i).getIs_type());
                                tv3.setText("意见: " + zdrwXqBeans.get(i).getYi_jian());
                                root.addView(view);
                            }
                        }
                    }

                    @Override
                    public void errowithresponse(String str) {

                    }

                    @Override
                    public void erro() {

                    }

                    @Override
                    public void finish() {

                    }
                });

    }

    @Override
    public void initData() {

    }


    @OnClick(R.id.back_iv)
    public void onViewClicked() {
        finish();
    }
}
